import java.util.Scanner;
import java.util.ArrayList;
import java.util.List;

public class Main8 {

    public static List<String> convertStringToList(String line) {
            String[] s=line.split(" ");
            List<String> list=new ArrayList<>();
            for (int i=0;i<s.length ;i++ ) {
                    list.add(s[i]);
            }
             int n=list.size();
            for (int i=0;i<n ;i++ ) {
                    if (list.get(i).compareTo("")==0) {
                            list.remove(i);
                            n--;
                            i--;
                    }
            }
            return list;
    }
		
    public static void remove(List<String> list, String str){
            int n=list.size();
            for (int i=0;i<n ;i++ ) {
                    if (str.compareTo(list.get(i))==0) {
                            list.remove(i);
                            n--;
                            i--;
                    }
            }
    }
		
     public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextLine()){
            List<String> list = convertStringToList(sc.nextLine());
            System.out.println(list);
            String word = sc.nextLine();
            remove(list,word);
            System.out.println(list);
        }
        sc.close();
    }

}